package com.haste;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

/**
 * @ClassName:DeptProvider8001
 * @Description:
 * @Author:Haste
 * @Date:2021/2/1 17:48
 */
@EnableEurekaClient //在服务启动后自动注册到注册中心
@SpringBootApplication
@EnableCircuitBreaker //添加熔断支持
public class DeptHystrix8001 {
    public static void main(String[] args) {
        SpringApplication.run(DeptHystrix8001.class,args);
    }
    //让其被Hystrix监控
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet (){
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        registrationBean.addUrlMappings("/actuator/hystrix.stream");
        return registrationBean;
    }
}
